package com.Enumeration枚举类;

/**
 * 作    者 ：吾路巴尼
 * 创建时间 ：2025-02-20:32
 */
public class enum枚举的实现_enum关键字实现枚举 {
    /**
     * 枚举的两种是想方式：
     * 1.自定义类实现枚举：
     * 2.使用enum 关键字，实现枚举
     */
    public static void main(String[] args) {
        System.out.println(Season02.SPRING);  //一样可以直接用类名访问对象；
        System.out.println(Season02.SUMMER);
        System.out.println(Season02.AUTUMN);
        System.out.println(Season02.WINTER);

    }
}
/**2.使用enum 关键字，实现枚举*/
enum Season02{
    /**
     *  1.把set方法去除，防止被修改
     * 2.私有化构造器，防止外部创建对象
     * 3.把class改成enum
     * 4.把public static final Season02 SPRING = new Season02("春天","春暖花开") 改成 SPRING("春天","春暖花开") ；
     * 5.对象必须放在第一行，并且每个对象之间 逗号 隔开
     * 6.SPRING("春天","春暖花开") 默认是 public static final Season02 SPRING = new Season02("春天","春暖花开")；
     */
//    public static final Season02 SPRING = new Season02("春天","春暖花开");
//    public static final Season02 SUMMER = new Season02("夏天","夏日炎炎");
//    public static final Season02 AUTUMN = new Season02("秋天","秋高气爽");
//    public static final Season02 WINTER = new Season02("冬天","冰天雪地");
            /**把上面的简化成下面的样式  每个对象之间 逗号 隔开，并且必须放在第一行*/
    SPRING("春天","春暖花开"),SUMMER("夏天","夏日炎炎"),
    AUTUMN("秋天","秋高气爽"),WINTER("冬天","冰天雪地");
    private String name;
    private String desc;
    private Season02(String name,String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return "Season02{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}